blob: ce43a79d02776d9924c2b65b386d62a38dec0086 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
<script>
import { PUBLIC_RECAPTCHA_SITE_KEY } from "$env/static/public";
import { browser } from "$app/environment";
import { onDestroy, onMount, tick } from "svelte";
import { t } from "$lib/translations";
import PasswordInput from "$comp/PasswordInput.svelte";
import Icon from "$comp/Icon.svelte";
import Spinner from "$comp/Spinner.svelte";
import { fly } from "svelte/transition";
import { password } from "$lib/store";
import { fail } from "$lib/utils";
let { form } = $props();
let email;
let loading;
let recaptchaToken = "";
let recaptchaSiteKey = PUBLIC_RECAPTCHA_SITE_KEY;
let isTor = browser && location.hostname.endsWith(".onion");
onMount(() => {
if (!isTor && recaptchaSiteKey) {
let s = document.createElement("script");
s.src = "https://www.google.com/recaptcha/api.js?render=" + recaptchaSiteKey;
document.head.appendChild(s);
}
});
const getRecaptchaToken = () =>
new Promise((resolve, reject) => {
if (isTor) return resolve("");
if (!browser || !grecaptcha) return reject(new Error("captcha unavailable"));
grecaptcha.ready(() => {
grecaptcha
.execute(recaptchaSiteKey, { action: "reset" })
.then(resolve)
.catch(reject);
});
});
const handleSubmit = async (e) => {
e.preventDefault();
loading = true;
try {
recaptchaToken = await getRecaptchaToken();
await tick();
e.currentTarget.submit();
} catch (err) {
fail(err.message || "captcha failed");
loading = false;
}
};
onDestroy(() => {
if (!browser) return;
const nodeBadge = document.querySelector(".grecaptcha-badge");
if (nodeBadge) {
document.body.removeChild(nodeBadge.parentNode);
}
const scriptSelector =
"script[src='https://www.google.com/recaptcha/api.js?render=" +
recaptchaSiteKey +
"']";
const script = document.querySelector(scriptSelector);
if (script) {
script.remove();
}
});
</script>
<div class="pt-10">
<div class="w-[243px] mx-auto mb-10">
<a href="/">
<Icon icon="logo" />
</a>
</div>
<div class="flex justify-center items-center">
<div
class="shadow-xl rounded-3xl p-10 pb-12 space-y-5 w-full mx-5 md:mx-0 md:w-[400px]"
>
<h1 class="text-2xl font-bold text-center">{$t("login.reset")}</h1>
{#if form?.error}
<div class="text-red-600 text-center" in:fly>
{form.error}
</div>
{/if}
<form class="space-y-5" method="POST" onsubmit={handleSubmit}>
<input type="hidden" name="recaptcha" value={recaptchaToken} />
<PasswordInput
bind:value={$password}
placeholder={$t("login.password")}
/>
<div class="text-secondary">
A new seed phrase will be generated for your account. You'll need to
import your old seed phrase if you want to use the same nostr profile
and savings account as before.
</div>
<button
type="submit"
class="bg-black text-white w-full rounded-2xl p-4 font-semibold hover:opacity-80"
disabled={loading}
>
{#if loading}
<Spinner />
{:else}
{$t("login.submit")}
{/if}
</button>
</form>
</div>
</div>
</div>
|